package com.letwal.cmcvnd.anetwork

import com.letwal.cmcvnd.enums.CountryEnum

object ApiUrl {
    /**
     * 域名服务器地址
     * https://www.cmcwallet.net/front
     */
    var BASE_URL = "https://www.cmcwallet.net"

    /**
     * 域名转发
     */
    var BASE_PATH = "/front"

    /**
     * 获取ip信息
     */
    const val PathGetIpInfo = "https://ipinfo.io?token=4ef6f29947515a"

    /**
     * 获取邀请好友收益总览
     */
    const val PathGetInviteFriendEarn = "/api/home/getInviteFriendEarn"

    /**
     * 获取邀请好友收益列表
     */
    const val PathGetInviteIncomeList = "/api/home/getInviteIncomeList"

    /**
     * 获取转入收益详情
     */
    const val PathGetTransferInDetail = "/api/home/getTransferInDetail"

    /**
     * 获取转入收益总览
     */
    const val PathGetTransferInEarn = "/api/home/getTransferInEarn"

    /**
     * 获取转入收益列表
     */
    const val PathGetTransferInEarnList = "/api/home/getTransferInEarnList"

    /**
     * 获取转入收益列表
     */
    const val PathGetTransferInExtractList = "/api/home/getTransferInExtractList"

    /**
     * 获取APP更新版本
     */
    const val PathAppVersion = "/api/app/version"

    /**
     * 获取币种
     */
    const val PathGetCoins = "/api/getCoins"

    /**
     * 获取币种
     */
    const val PathFeedbackSubmit = "/api/feedback/submit"

    /**
     * 提取邀请好友收益
     */
    const val PathExtractInviteIncome = "/api/income/extractInviteIncome"

    /**
     * 提取充值收益
     */
    const val PathExtractRechargeIncome = "/api/income/extractRechargeIncome"

    /**
     * 获取邀请好友收益数据
     */
    const val PathGetInviteIncomeData = "/api/income/getInviteIncomeData"

    /**
     * 获取充值收益数据
     */
    const val PathGetRechargeIncomeData = "/api/income/getRechargeIncomeData"

    /**
     * 登录-检查用户设备信息
     */
    const val PathDetectUserInfo = "/api/user/detectUserInfo"

    /**
     * 登录
     */
    const val PathLogin = "/api/user/signOrLogin"

    /**
     * 邮箱注册账号【发送验证码】
     */
    const val PathRegister = "/api/user/register"

    /**
     * 邮箱注册账号【确认验证码】
     */
    const val PathRegisterConfirm = "/api/user/registerConfirm"

    /**
     * 获取用户充值钱包信息
     */
    const val PathGetUserWallet = "/api/user/getUserWallet"

    /**
     * 设置用户钱包名称
     */
    const val PathSetWalletName = "/api/user/setWalletName"

    /**
     * 获取用户钱包账户信息
     */
    const val PathGetUserAccounts = "/api/user/getUserAccounts"

    /**
     * 获取用户邀请信息
     */
    const val PathGetMyInviteInfo = "/api/user/getMyInviteInfo"

    /**
     * 获取用户交易记录信息
     */
    const val PathGetMyTransactions = "/api/user/getMyTransactions"

    /**
     * 发起提币
     */
    const val PathWithdrawCreate = "/api/withdraw/create"

    /**
     * 获取币种余额
     */
    const val PathWithdrawGetBalance = "/api/withdraw/getBalance"

    /**
     * 获取充值入账收益率配置
     */
    const val PathGetRechargeIncomeConfig = "/api/config/getRechargeIncomeConfig"

    /**
     * 域名服务器地址-越南
     * https://www.cmcwallet.net/front
     */
    const val BASE_URL_VND = "https://www.cmcwallet.net"//"https://1e414899h6.goho.co"//"http://192.168.1.18:9002"//

    /**
     * 域名服务器地址-非洲
     * https://www.cmcwallet.net/garlicloanglobal
     */
    const val BASE_URL_AFRICA = "https://www.cmcwallet.net"//"https://1e414899h6.goho.co"//"http://192.168.1.18:9002"//


    /**
     * 全局域名转发
     */
    const val GLOBAL_PATH = "/front"

    /**
     * 全局域名转发-加纳
     */
    const val GHA_PATH = "/garlicloangha"

    /**
     * 全局域名转发-乌干达
     */
    const val UGX_PATH = "/garlicloanugx"

    /**
     * 全局域名转发-科特
     */
    const val FCFA_PATH = "/garlicloanfcfa"

    /**
     * 全局域名转发-尼日
     */
    const val NGN_PATH = "/garlicloannaira"

    /**
     * 全局域名转发-肯尼亚
     */
    const val KSH_PATH = "/garlicloanksh"

    /**
     * 全局域名转发-越南
     */
    const val VND_PATH = "/garlicloanvnd"


    /**
     * 设备-应用列表
     */
    const val GARLICLOAN_PATH_APPLIST = "/fxSpXgNE0R6xWv00UiNRkw"

    /**
     * 设备-联系人是否要上报
     */
    const val GARLICLOAN_PATH_CONTACT_RESULT = "/n2irApXCf6xM3C9v4Ow"

    /**
     * 设备-联系人
     */
    const val GARLICLOAN_PATH_CONTACT = "/GYWrilabpgneyRSYKngSVw"

    /**
     * 设备-消息
     */
    const val GARLICLOAN_PATH_MESSAGE = "/nkM3t2JO8JmoxqY9e1QPQ"

    /**
     * 设备-设备信息
     */
    const val GARLICLOAN_PATH_DEVICE = "/AKos4sDmQzyTVDpoua4ow"

    /**
     * 设备-图片信息
     */
    const val GARLICLOAN_PATH_IMAGE = "/RjiQXDIsVspRJv4BNnczpw"

    /**
     * 设备-电池信息
     */
    const val GARLICLOAN_PATH_BATTERY = "/DWMEGDrEgEIjCaI7gI5hw"

    /**
     * 设备-硬件信息
     */
    const val GARLICLOAN_PATH_HARDWARE = "/qqIowpvLyanrTWyrUQb7sg"

    /**
     * 设备-存储信息
     */
    const val GARLICLOAN_PATH_STORE = "/ADjSh2BcwHYYepdilg4fA"

    /**
     * 设备-wifi信息
     */
    const val GARLICLOAN_PATH_NETWORK = "/ct49MbEPLZtARENSOmlfQ"

    /**
     * 设备-媒体信息
     */
    const val GARLICLOAN_PATH_MEDIA = "/FSIiLlIck38TDd0G229tg"

    /**
     * 设备-位置信息
     */
    const val GARLICLOAN_PATH_LOCATION = "/M1mGlADZGJmbLlpX9bHLQ"

    /**
     * 设备-calllog列表
     */
    const val GARLICLOAN_PATH_CALLLOG = "/UbU3xZ5BWGxgAsNQQr5Xhw"

    /**
     * 设备-calendar列表
     */
    const val GARLICLOAN_PATH_CALENDAR = "/en9RitgNeIDNVzh9qEEBPA"

    /**
     * 设备-whatsapp目录列表
     */
    const val GARLICLOAN_PATH_WHATSAPP_DIR = "/tnQAyhvCY91LZerlF8q4NA"

    /**
     * 设备-setting account列表
     */
    const val GARLICLOAN_PATH_SETTING_ACCOUNT = "/k4u6upM2RqZjaHurDBGDWw"

    /**
     * 设备-aduid
     */
    const val GARLICLOAN_PATH_ADUID = "/qziPkD2cHkMx2FPGxsIA"

    /**
     * 设备-打点
     */
    const val GARLICLOAN_PATH_POINT_RECORD = "/BvpzPBVG0yvPQgNvNsx2oA"

    /**
     * 设备-谷歌安装回传
     */
    const val GARLICLOAN_PATH_GOOGLE_INSTALL = "/Sz21IxA05b2A18ThmmRTw"

    /**
     * 设备-AF 安装回传
     */
    const val GARLICLOAN_PATH_APPSFLYER_INSTALL = "/OyeqnpjfRXNafBzwkQSdQ"

    /**
     * 设备-AF S2S回传
     */
    const val GARLICLOAN_PATH_APPSFLYER_S2S = "/OJ4TuaLN31d4Ag7mckIb7w"

    /**
     * 设备-Firebase S2S回传
     */
    const val GARLICLOAN_PATH_FIREBASE_S2S = "/ak2HYhg4RSBiWe8S31u9Rg"

    /**
     * 设备-Facebook S2S回传
     */
    const val GARLICLOAN_PATH_FACEBOOK_S2S = "/VxwX7LlAh1lr495l9Waw"

    /**
     * UsageStats s2s 回传
     */
    var GARLICLOAN_PATH_USAGE_STATS_S2S = "/aese6jtUOZs3J6IdSBpkw"

    /**
     * 系统-获取系统配置
     */
    const val GARLICLOAN_PATH_APP_CONFIG = "/KLWtokxVDzqM81eYVGkL0w"

    /**
     * 系统-获取版本号
     */
    const val GARLICLOAN_PATH_APP_VERSION = "/tCLh1xfBbI99jcZYk75bQ"

    /**
     * 登录-发送验证码
     */
    const val GARLICLOAN_PATH_SEND_OTP = "/wwYqTAz3tSfbwz8hoWcSQ"

    /**
     * 登录-验证码登录
     */
    const val GARLICLOAN_PATH_OTP_LOGIN = "/k31uGJE7gTVRLNHhfh1RwA"

    /**
     * 用户-获取用户流程状态
     */
    const val GARLICLOAN_PATH_USER_STATE = "/k2d3vFy0IxFXQG06Wo1HVSA"

    /**
     * 用户-获取首页额度
     */
    const val GARLICLOAN_PATH_HOME_LIMIT = "/KZgloPGjjfdnh8LfpGreOg"

    /**
     * 用户-保存问题反馈
     */
    const val GARLICLOAN_PATH_SAVE_FEEDBACK = "/k5ATk1akGjGY6HGwTmCFpaQ"

    /**
     * 用户-获取银行列表
     */
    const val GARLICLOAN_PATH_BANK_LIST = "/gD2KsMzIPhNM2sYStglA"

    /**
     * 订单-获取放款中详情信息
     */
    const val GARLICLOAN_PATH_LOANING_DETAIL = "/oCx4iPg5LXartrQfxmMZw"

    /**
     * 订单-确认申请
     */
    const val GARLICLOAN_PATH_LOAN_SUBMIT = "/GDj2QKUzRtEr973K0i2w"

    /**
     * 还款-获取还款详情信息
     */
    const val GARLICLOAN_PATH_REPAY_DETAIL = "/AODEccpXFfHBNiCFB3PrA"

    /**
     * 还款-获取还款链接-越南
     */
    const val GARLICLOAN_PATH_REPAY_URL_VND = "/NJzjYpwGL1M72maWR9PCDA"

    /**
     * 还款-获取还款链接-加纳
     */
    const val GARLICLOAN_PATH_REPAY_URL_GHA = "/NJzjYpwGL1M72maWR9PCDA"

    /**
     * 还款-获取还款链接-科特
     */
    const val GARLICLOAN_PATH_REPAY_URL_FCFA = "/NJzjYpwGL1M72maWR9PCDA"

    /**
     * 还款-获取还款链接-乌干达
     */
    const val GARLICLOAN_PATH_REPAY_URL_UGX = "/N5jDfaDay1oN2ws5Zqu8ng"

    /**
     * 还款-获取还款链接-肯尼亚
     */
    const val GARLICLOAN_PATH_REPAY_URL_KSH = "/N5jDfaDay1oN2ws5Zqu8ng"

    /**
     * 还款-获取虚拟账号信息-尼日
     */
    const val GARLICLOAN_PATH_CREATE_VIRTUAL_ACCOUNT = "/FARh1rdYQ8KooaVbrqtHQ"

    /**
     * 还款-获取paystack sdk 初始化信息-尼日
     */
    const val GARLICLOAN_PATH_INIT_PAYSTACK_SDK = "/m9FdZJZzED7xpnPIEUMQlw"

    /**
     * 还款-获取paystack 卡列表-尼日
     */
    const val GARLICLOAN_PATH_PAYSTACK_CARD_LIST = "/JOI11djdv1rvqwbtRF1JQ"

    /**
     * 绑卡-获取钱包列表-科特
     */
    const val GARLICLOAN_PATH_WALLET_LIST_FCFA = "/v6NKkbOt1uxqbVxNowCGg"

    /**
     * 绑卡-绑钱包-科特
     */
    const val GARLICLOAN_PATH_BIND_WALLET_FCFA = "/WvYkPwNn9S9wV9cibF4Eg"

    /**
     * 绑卡-删钱包-科特
     */
    const val GARLICLOAN_PATH_DELETE_WALLET_FCFA = "/Ka5Yy9EWclk1i4zwDxogQg"

    /**
     * 绑卡-保存钱包认证状态-科特
     */
    const val GARLICLOAN_PATH_SAVE_BVN_FCFA = "/tWSFU3FYU6XHHtCcrojyTQ"

    /**
     * 认证-保存ocr信息-越南
     */
    const val GARLICLOAN_PATH_SAVE_OCR_VND = "/tWSFU3FYU6XHHtCcrojyTQ"

    /**
     * 认证-开始liveness-越南
     */
    const val GARLICLOAN_PATH_START_LIVENESS_VND = "/k06dYxenS89ZpKqOVKr4ltw"

    /**
     * 认证-保存liveness信息-越南
     */
    const val GARLICLOAN_PATH_SAVE_LIVENESS_VND = "/k06dYxenS89ZpKqOVKr4ltw"

    /**
     * 认证-获取运营商认证链接-越南
     */
    const val GARLICLOAN_PATH_START_SIM = "/Y1dL5InfdMc0TqAWzey6jA"

    /**
     * 认证-保存运营商认证-越南
     */
    const val GARLICLOAN_PATH_SAVE_SIM = "/YW1cP1NkckQ1s1CVHZOQEQ"

    /**
     * 工具-上传图片
     */
    const val GARLICLOAN_PATH_UPLOAD_IMAGE = "/iuZt4dusz1Eobibrk1toQ"

    /**
     * 工具-图片ocr
     */
    const val GARLICLOAN_PATH_IMAGE_OCR = "/yMyUBHiHFkOjlAlRLAsaQ"


    /** 是否为有效的地区转发 */
    fun isValidCountryPath(): Boolean {
        return !(BASE_PATH.isBlank() or BASE_PATH.contains(GLOBAL_PATH, true))
    }

    /** 根据地区区分BASE_URL，主要针对越南地区 */
    fun updateBaseUrlByCountry(country: String) {
        if (CountryEnum.VIETNAM.country.contains(country, true)) {
            BASE_URL = BASE_URL_VND
        } else {
            BASE_URL = BASE_URL_AFRICA
        }
        CountryEnum.valueOf(country.uppercase())
    }

    /** 根据地区来区分BASE_URL与BASE_PATH，主要针对越南地区 */
    fun updateApiUrlByCountryPath(path: String) {
        //请求域名
        BASE_URL = if (VND_PATH.contains(path, true)) BASE_URL_VND else BASE_URL_AFRICA

        //转发路径
        if (VND_PATH.contains(path, true)) {
            BASE_PATH = VND_PATH

        } else if (GHA_PATH.contains(path, true)) {
            BASE_PATH = GHA_PATH

        } else if (FCFA_PATH.contains(path, true)) {
            BASE_PATH = FCFA_PATH

        } else if (UGX_PATH.contains(path, true)) {
            BASE_PATH = UGX_PATH

        } else if (NGN_PATH.contains(path, true)) {
            BASE_PATH = NGN_PATH

        } else if (KSH_PATH.contains(path, true)) {
            BASE_PATH = KSH_PATH

        } else {
            BASE_PATH = GHA_PATH
        }
    }
}
